package com.gupaoedu.mybatis.newlife;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

public class WDTMapperProxy implements InvocationHandler {
    private WDTSqlSession sqlSession;

    public WDTMapperProxy(WDTSqlSession sqlSession) {//注入sqlSesion
        this.sqlSession = sqlSession;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
    if (method.getDeclaringClass().getName().equals(WDTConfiguration.TestMapperXML.namespace)){
        String sql=   WDTConfiguration.TestMapperXML.methodSqlMapping.get(method.getName());
        sqlSession.selectOne(sql,String.valueOf(args[0]));
    }

        return method.invoke(this,args);
    }
}
